import { request } from '@/utils/request'

export type LoginUserRequest = {
  phone: string;
  password: string;
}

export function createOrUpdate (menu: object) {
  return request.post('/boss/menu/saveOrUpdate', menu)
}
// {
// "id": null,
// "parentId": -1,
// "name": "test_1",
// "href": "test_1_url",
// "icon": "test_1_",
// "orderNum": 0,
// "description": "",
// "shown": true
// }

export function getEditMenuInfo (id: number) {
  return request.get('/boss/menu/getEditMenuInfo', { params: { id } })
}

export function getAll () {
  return request.get('/boss/menu/getAll')
}

export function deleteMenu (id: number | string) {
  return request.delete(`/boss/menu/${id}`)
}

export function getRoleMenus (roleId: number | string) {
  return request.get('/boss/menu/getRoleMenus', { params: { roleId } })
}
export function allocateRoleMenus (roleId: number | string, menuIdList: number|string[]) {
  return request.post('/boss/menu/allocateRoleMenus', { menuIdList, roleId })
}
